package servlet;

import dao.UserDAO1;
import entity.PageBean;
import entity.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name="UserFindById", value = "/user/findById")
public class UserFindById extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 根据id传回用户信息
        String id = req.getParameter("id");
        UserDAO1 userDAO1 = new UserDAO1();
        User user = userDAO1.findById(id);
        req.setAttribute("user", user);  // 设置属性
        req.getRequestDispatcher("/user/Remove.jsp").forward(req,resp);
        System.out.println(user);
    }
}
